<template>
	<view class="page">
		<!--  评价成功 wwl -->
		<view class="info">
			<view class="type">
				<n-icon name="roundcheckfill" size="46" color='#fd7a22'></n-icon>
				<text style="margin-left: 10rpx;">评价成功</text>
			</view>
			<view class="text">
				感谢您发表的评价，您的评论会帮助更多的人~
			</view>
			<view class="btn_box">
				<text @click="onBak()">返回首页</text>
				<text @click="onDetail()">查看评论</text>
			</view>
		</view>
		<view class="list" v-if='total  > 0'>
			<view class="row_title">
				<text class="row row1"></text>
				<text class="text">还有这些宝贝未评论</text>
				<text class="row row2"></text>
			</view>
			<view class="row" v-for="(row,i) in list" :key='i' >
				<image :src="row.goods_cover" class="left" mode="scaleToFill"></image>
				<view class="right">
					<view class="title">
						{{row.goods_name}}
					</view>
					<view class="btn" @click="oneEvaluate(row)">
						写评价
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {getOrderList} from "../static/api.js"
	export default {
		data() {
			return {
				page: 1,
				loading: false,
				size: 12,
				total: 0,
				list: [],
				goods_id: null,
				type: null,
				statusList: [{
						id: 1,
						type: 'findDesign',
						name: '设计师'
					},
					{
						id: [3, 4, 5, 6, 7, 8, 9, 10],
						type: 'buildingMaterialsCity',
						name: '建材成'
					},
					{
						id: 2,
						type: 'findCraftsman',
						name: '工匠'
					},
					{
						id: 11,
						type: 'newHouseAcceptance',
						name: '新房验收'
					},
					{
						id: 11,
						type: 'thirdPartySupervision',
						name: '三方监理'
					}
				]
			}
		},
		methods: {
			oneEvaluate(row){
				uni.navigateTo({
					url: '/pagesMy/order/evaluate?id=' + row.id + '&type=' + row.type + '&goods_id=' + row.goods_id
				})
			},
			onBak() {
				uni.reLaunch({
					url: '/pages/index/index'
				})
			},
			onDetail() {
				var type = null
				this.statusList.forEach(x => {
					if (typeof(x.id) == "number" && x.id == this.type) {
						type = x.type
					} else if (typeof(x.id) == "object" && x.id.indexOf(Number(this.type)) != -1) {
						type = x.type
					}
				})
				uni.redirectTo({
					url: '/pagesCommodity/information?id=' + this.goods_id + '&type=' + type
				})
			},
			async  getList() {
				this.loading = true
				try {
					var res = await getOrderList({
						status: 5,
						limit: this.size,
						page: this.page
					})
					if (res.count > 0) {
						this.list = this.page == 1 ? res.list : [...this.list, ...res.list]
					}
					this.total = res.count
					this.loading = false
				} catch {
					this.loading = false
				}
			}
		},
		onReachBottom(x) {
			if (this.page * this.limit >= this.total || this.loading) return
			this.page++
			this.getList()
		},
		onLoad(params) {
			this.goods_id = params.goods_id
			this.type = params.type
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.info {
		padding: 60rpx 36rpx 140rpx;
		width: 100%;
		box-sizing: border-box;

		.type {
			color: #26252A;
			font-size: 36rpx;
			line-height: 50rpx;
			text-align: center;
			font-weight: 700;
		}

		.text {
			text-align: center;
			margin-top: 32rpx;
			font-size: 28rpx;
			line-height: 40rpx;
			color: #666666;
		}

		.btn_box {
			margin-top: 84rpx;
			text-align: center;

			text {
				display: inline-block;
				width: 184rpx;
				height: 60rpx;
				background: #f6f7fb;
				border-radius: 30rpx;
				color: #ADADAD;
				font-size: 24rpx;
				text-align: center;
				line-height: 60rpx;

				&:last-child {
					margin-left: 60rpx;
				}
			}
		}
	}

	.list {
		.row_title {
			margin-bottom: 58rpx;
			display: flex;
			justify-content: center;
			align-items: center;

			.text {
				font-size: 28rpx;
				line-height: 40rpx;
				font-family: PingFang SC, PingFang SC-Semibold;
				padding: 0 30rpx;
				color: #666666;
			}

			.row {
				width: 25%;
				height: 2rpx;
			}

			.row1 {
				background: linear-gradient(60deg, #ffffff 6%, #adadad 82%);
			}

			.row2 {
				background: linear-gradient(60deg, #adadad 6%, #ffffff 82%);
			}


		}

		padding: 0 36rpx;
		width: 100%;
		box-sizing: border-box;

		>.row {
			display: flex;
			justify-content: space-between;
			padding: 40rpx 24rpx;
			width: 100%;
			box-sizing: border-box;
			background: #ffffff;
			border-radius: 16rpx;
			box-shadow: 0px 4rpx 12rpx 0px rgba(0, 0, 0, 0.05);
			margin-bottom: 40rpx;

			.left {
				width: 104rpx;
				height: 104rpx;
			}

			.right {
				width: calc(100% - 120rpx);
				display: flex;
				justify-content: space-between;
				align-items: center;

				.title {
					width: calc(100% - 156rpx);
					font-size: 24rpx;
					line-height: 34rpx;
					color: #26252A;
					overflow: hidden;
					text-overflow: ellispsis;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
				}

				.btn {
					width: 116rpx;
					height: 60rpx;
					background: #ffffff;
					border: 2rpx solid #fd9826;
					border-radius: 32rpx;
					color: #FF9800;
					font-size: 24rpx;
					line-height: 60rpx;
					text-align: center;
				}
			}
		}
	}
</style>
